package com.bdsy.business.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bdsy.business.dao.TransactionRecordsMapper;
import com.bdsy.business.model.TransactionRecords;
import com.bdsy.business.service.TransactionRecordsService;
import com.bdsy.common.utils.DateUtil;

@Service("transactionRecordsService")
public class TransactionRecordsServiceImpl implements TransactionRecordsService {

	@Autowired
	TransactionRecordsMapper transactionRecordsMapper;
	
	@Override
	public boolean insert(TransactionRecords transactionRecords) {
		transactionRecords.setId((int)((Math.random()*9+1)*10000000));
		transactionRecords.setTime(DateUtil.getCurrentDate());
		int result = transactionRecordsMapper.insert(transactionRecords);
		return result>0?true:false;
	}

	@Override
	public List<Map> selectTransactionRecordsByShopId(int shopId) {
		List<Map> transactionRecords= transactionRecordsMapper.selectTransactionRecordsByShopId(shopId);
		return transactionRecords;
	}

	@Override
	public boolean deleteTransactionRecordsById(List<String> pIds) {
		int result = transactionRecordsMapper.delete(pIds);
		return result>0?true:false;
	}

	@Override
	public List<Map> selectTransactionRecordsByUserId(String userId) {
		List<Map> transactionRecordsList = transactionRecordsMapper.selectTransactionRecordsByUserId(userId);
		return transactionRecordsList;
	}

}
